package com.wlstock.funi.MissionInstance;

import android.content.Context;

import com.em.mission.MissionQueue;
import com.wlstock.funi.fundenum.KLINE_PERIOD;
import com.wlstock.funi.model.SelfFundHisModel;

import java.util.List;

/**
 * Created by admin on 16/9/25.
 */

public class KLineMissionQueue extends MissionQueue {

    private static KLineMissionQueue instance;

    private KLineMissionQueue(Context mContext, String name) {
        super(mContext, name);
    }


    public static KLineMissionQueue getInstance(Context mContex, String name) {
        if (instance == null) {
            synchronized (KLineMissionQueue.class) {
                if (instance == null) {
                    instance = new KLineMissionQueue(mContex,name);
                }
            }
        }
        return instance;
    }


    public MissionQueue addKLineMissions(List<SelfFundHisModel> sfHisModels){
        if (sfHisModels!=null && !sfHisModels.isEmpty()){
            for (int i = 0 ; i < sfHisModels.size() ; i++){
                this.addKLineMissions(sfHisModels.get(i));
            }
        }
        return this;
    }

    public MissionQueue addKLineMissions(SelfFundHisModel sfHisModel){
//        addKLineMission(sfHisModel,KLINE_PERIOD.MIN5);
//        addKLineMission(sfHisModel,KLINE_PERIOD.MIN10);
        addKLineMission(sfHisModel,KLINE_PERIOD.MIN30);
        addKLineMission(sfHisModel,KLINE_PERIOD.MIN60);
        addKLineMission(sfHisModel,KLINE_PERIOD.DAY);
        return this;
    }

    private void addKLineMission(SelfFundHisModel sfHisModel, KLINE_PERIOD period){
        try {
            SelfFundHisModel sf5MinModel = sfHisModel.clone();
            sf5MinModel.setKLINEPeriod(period);
            addMission(new MinPeriodKLineMission(mContext, sf5MinModel));
        }catch (CloneNotSupportedException e){
            e.printStackTrace();
        }
    }



}
